package com.hualan.servlet;

import com.alibaba.fastjson.JSON;
import com.hualan.bean.PanghuCommunity;
import com.hualan.dao.CommunityDao;
import com.hualan.dao.CommunityDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Result;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/delete/community")
public class CommunityDeleteServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //通过id删除
      Integer communityid = Integer.parseInt(req.getParameter("communityId"));
        CommunityDao communityDao = new CommunityDaoImpl();
       int row = communityDao.deleteCommunity(communityid);
        Map<String, Object> map = new HashMap<>();
        if (row > 0){
            map.put("code",200);
        }else {
            map.put("code",300);
        }

        resp.getWriter().write(JSON.toJSONString(map));
    }




    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
